<template>
  <div class="form">
    <el-form ref="form" :model="form" label-width="80px" :label-position="labelPosition">
      <el-form-item label="客服电话">
        <el-input v-model="form.mobile" style="width: 220px;" maxlength="11"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import {
    getServiceMoblie,
    setMobile
  } from '@/api/set.js';
  export default {
    data() {
      return {
        labelPosition: 'right',
        form: {
          mobile: ''
        }
      }
    },
    created() {
      this.getMobile()
    },
    methods: {
      onSubmit() {
        // console.log(this.form.mobile);
        setMobile({
          mobile:this.form.mobile
        }).then(res=>{
          if(res.code == 1){
            location.reload();
            this.$message.success(res.message)
          }
        })
      },
      getMobile() {
        getServiceMoblie().then(res=>{
          if(res.code == 1){
            this.form.mobile = res.data
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .form {
    margin: 50px;
  }
</style>
